/* Name: StartBtn
 * Author: John Gideon
 * Date: 5-4-12
 * Description: Button used to start the game
 * Revisions: See Subversion logs at http://code.google.com/p/software-engineering-2012/source/list
 */

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;

public class StartBtn extends Button {
	private int width;
	private int height;
	
	// Creates a button at the given location, ith the given dimensions
	public StartBtn(int px, int py, int pwidth, int pheight) {
		super(px, py, pwidth, pheight);
		Game.create((Item)this, 1); // Needed for update, draw, and destroy
		colType = COL_NONE; // Needed for collision checking
		width = pwidth;
		height = pheight;
	}
	
	// Called whenever the button is pressed
	protected void pressed() {
		Sound.stopMusic();
		Sound.effect(Sound.EFFECT_START);
		StartScreen.setupNewRound();
		Game.gotoRoom(Game.ROOM_GAME);
	}
	
	// Called when new frames are drawn on screen - properly draws button
	public void draw() {
		Graphics2D gh = Game.getGraphicsHandle();
		if (btnDrawState == Button.BTN_STATE_OFF) {gh.setColor(Color.GRAY);}
		else if (btnDrawState == Button.BTN_STATE_HOVER) {gh.setColor(Color.LIGHT_GRAY);}
		else {gh.setColor(Color.DARK_GRAY);}
		gh.fillRoundRect(x, y, width, height, 15, 15);
		gh.setFont(new Font("Serif", Font.PLAIN, 40));
		gh.setColor(Color.BLUE);
		String text = "START";
		FontRenderContext frc = gh.getFontRenderContext();
		Rectangle2D rect = gh.getFont().getStringBounds(text, frc);
		gh.drawChars(text.toCharArray(), 0, text.length(), (int)(x + width/2 - rect.getWidth()/2), (int)(y + height/2 + rect.getHeight()/2)-10);
	}
	
	public void update() {updateBtn();}
	public void leftMousePress() {leftMousePressBtn();}
	public void leftMouseRelease() {leftMouseReleaseBtn();}
}
